<?php

use yii\db\Migration;

/**
 * Handles the creation of table `groupbuy`.
 */
class m181212_020736_create_groupbuy_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%groupbuy}}', [
            'id' => $this->primaryKey(),
            'user1'=>$this->integer(5)->notNull()->comment('团长'),
            'users'=>$this->text()->comment('参与者'),
            'goodsid'=>$this->integer(5)->notNull()->comment('商品id'),
            'createtime'=>$this->dateTime()->notNull()->comment('创建时间'),
            'endtime'=>$this->dateTime()->comment('成功时间'),
            'status'=>$this->integer(1)->defaultValue(0)->comment('状态 0拼团中 1 拼团成功'),

        ],$tableOptions);
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%groupbuy}}');
        return true;
    }
}
